(function () {
    'use strict';

    angular
        .module('milkbeeApp')
        .controller('InstantController', InstantController);

    InstantController.$inject = ['$cookies', '$http', 'InstantService'];

    function InstantController ($cookies, $http, InstantService) {
        // This controller uses a Websocket connection to receive user activities in real-time.
        var vm = this;

        vm.instants = [];
        vm.focuses=[];
        InstantService.receive().then(null, null, function(newinstant) {
            //showInstants(newinstants);
        	vm.instants.splice(0,0,newinstant);
        });

        function showInstants(newinstants) {     
         /*   for (var index = 0; index < newinstants.length; index++) {
            	//vm.instants.push(newinstants[index]);
            	vm.instants.splice(0,0,newinstants[index]);
            }*/
        }
        vm.send=function(){
        	InstantService.sendInstant(vm.content);
        }
        function loadFocus(){
        	$http({
     			method: 'GET',
     			url: '/api/myfocus',
     			params:{}
     		}).then(function successCallback(response) {
     			// AlertService.error(response.data);
     			vm.focuses=response.data;
     		}, function errorCallback(response) {
     			// AlertService.error(response.data);
     		});
        }
        loadFocus();
    }
})();
